<?php

/**
 * proveedor actions.
 *
 * @package    tvpv
 * @subpackage proveedor
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class proveedorActions extends sfActions
{
  public function executeIndex($request)
  {
  	
  	/*$pager = new sfPropelPager('Proveedor',20);
  	$pager->setCriteria(new Criteria());
  	$pager->setPage($this->getRequestParameter('page'));
  	$pager->init();*/
    //$this->proveedorList = ProveedorPeer::doSelect(new Criteria());
      $this->proveedorList = ProveedorPeer::getAll($this->getRequestParameter('page'),$this->getRequestParameter('buscar'));
    if($request->getParameter('buscar') == '')
      $request->setParameter('buscar',null);
  }

  public function executeCreate()
  {
    $this->form = new ProveedorForm();

    $this->setTemplate('edit');
  }

  public function executeEdit($request)
  {
    $this->form = new ProveedorForm(ProveedorPeer::retrieveByPk($request->getParameter('id')));
  }

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new ProveedorForm(ProveedorPeer::retrieveByPk($request->getParameter('id')));

    $this->form->bind($request->getParameter('proveedor'));
    if ($this->form->isValid())
    {
      $proveedor = $this->form->save();

      $this->redirect('proveedor/index');
    }

    $this->setTemplate('edit');
  }

  public function executeDelete($request)
  {
    $this->forward404Unless($proveedor = ProveedorPeer::retrieveByPk($request->getParameter('id')));

    $proveedor->delete();

    $this->redirect('proveedor/index');
  }
}
